#include "all.h"

#if 0

PROCESS_POSIT_CMDLINE	PROC
		;
		;PROCESS A POSITIONAL MS-STYLE CMDLINE
		;
		;NOW, START PARSING THE COMMAND INPUT...
		;
		CALL	PARSE_OBJS
if	fg_plink
		JC	L99$			;COMMAND WAS /FREEFORMAT
endif
		CALL	PARSE_OUTFILE
		CALL	PARSE_MAPFILE
		CALL	PARSE_LIBS
if	fg_segm OR fg_pe
		CALL	PARSE_DEFFILE
		CALL	PARSE_RCS
endif
		RET

if	fg_plink
L99$:
		JMP	PROCESS_FREE_CMDLINE
endif

PROCESS_POSIT_CMDLINE	ENDP


PARSE_OBJS	PROC	NEAR
		;
		;HERE COME OBJS TO LINK
		;
		MOV	FILESTUFF_PTR,OFF OBJSTUFF
		CALL	VERIFY_SECTION
L1$:
		CALL	GETNST_SLASH		;HANDLE ANY SLASH COMMANDS...
		JC	L99$			;COMMAND WAS /FREEFORMAT...
		CMP	AL,','
		JZ	L65$			;OK, GO READ .EXE FILE
		CMP	AL,0DH
		JZ	L4$
		MOV	LAST_DELIM,0
		CMP	AL,'+'
		JZ	L3$			;ALLOWS IGNORING A CR
if	fg_ov
		CMP	AL,'('
		JZ	L5$
		CMP	AL,')'
		JZ	L6$
endif
		CMP	AL,';'
		JZ	L7$
		CMP	AL,1AH
		JZ	L7$
L2$:
		DEC	INPTR1
		PLUS_FOUND = 0;
		MOV	EAX,OFF OBJSTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM
		push	EAX
		call	_do_objs
		add	ESP,4
		JMP	L1$

L99$:
		PLUS_FOUND = 0;
		STC
		RET

L65$:
		;
		;GOT A COMMA
		;IF NEXT NON-BLANK IS A CR, DON'T COUNT IT...
		;
		CMP	LAST_DELIM,0DH		;IF LAST DELIMITER WAS A 0DH, SKIP THIS
		JMP	L45$

L4$:
		;
		;FOUND CR
		;
		CMP	LAST_DELIM,','
L45$:
		MOV	LAST_DELIM,0
		JNZ	L46$
		JMP	L1$

L46$:
		MOV	LAST_DELIM,AL
		CMP	SRCNAM.NFN_PRIMLEN,0	;IGNORE IF NO .OBJS YET
		JZ	L1$
		BITT	PLUS_FOUND
		PUSHFD
		PLUS_FOUND = 0;
		POPFD
		JZ	L71$
		JMP	L1$

L3$:
		;
		;FOUND +
		;
		PLUS_FOUND = 0xFF;
		JMP	L1$

if	fg_ov

L5$:
		;
		;FOUND (
		;
		BITT	PARSE_IN_OVERLAY	;IF ALREADY IN OVERLAY, ( IS FIRST CHAR OF FILENAME
		JNZ	L2$
		PARSE_IN_OVERLAY = 0xFF;
		CALL	REOPEN_AREA
		CALL	DO_NEW_SECTION		;SETUP NEW SECTION
		OR	FNTBL+')',MASK FNTBL_ILLEGAL
L59$:
		PLUS_FOUND = 0;
		JMP	L1$

L6$:

		;
		; ) IS END OF AN OVERLAY SECTION, UNLESS WE AREN'T IN ONE...
		;
		BITT	PARSE_IN_OVERLAY
		JZ	L61$
		PARSE_IN_OVERLAY = 0;
		AND	FNTBL+')',NOT MASK FNTBL_ILLEGAL
		CALL	ENDAREA_PROC
		JMP	L59$

endif

L7$:
		DEC	INPTR1
L71$:
		PLUS_FOUND = 0;
if	fg_ov
		BITT	PARSE_IN_OVERLAY
		JNZ	L61$
endif
		RET

if	fg_ov
L61$:
		MOV	AL,PAREN_NESTING_ERR
		CALL	ERR_INBUF_ABORT

endif

PARSE_OBJS	ENDP


GETNST_SLASH	PROC
		;
		;
		;
L1$:
		CALL	GETNST
		CMP	AL,'/'
		JZ	L5$
		CMP	AL,'-'
		JZ	L5$
		CLC
		RET


L5$:
		;
		;PROCESS COMMANDS FROM COMMAND LINE...
		;THIS IS JUMP TABLE HANDLER.
		;
		;COMMTBL LOOKS LIKE:
		;COMMTBL	DB	3	;MAX LENGTH OF COMMAND
		;		DB	3	;SIGNIFICANT CHARACTERS
		;		DW	COPROC	;ROUTINE IF THIS COMMAND
		;		DB	'CO:'	;ASCII FOR COMMAND
		;
		;		ETC
		;		ETC
		;DS & ES ARE DGROUP
		;
		PLUS_FOUND = 0;
		MOV	LAST_DELIM,0
		CALL	GET_KEYWORD	;PARSE IT OUT TO UPPER CASE
		XOR	EAX,EAX
		MOV	AL,SYMBOL_TEXT	;FIRST CHAR OF TOKEN
		SUB	AL,'A'		;DO TABLE LOOKUP ON START
		CMP	AL,'Z'-'A'
		JA	TRY_?

		MOV	ESI,MS_CMD_PTRS[EAX*4]	;START LOOKING HERE
MS_CHECK_NEXT:
		MOV	DL,[ESI]	;MAX LENGTH
		INC	ESI
		AND	EDX,03FH
		JZ	MS_BAD_CMD	;END OF TABLE
		MOV	BL,[ESI]
		INC	ESI		;SIG_CHARS
		MOV	ECX,EDX
		MOV	EAX,ESI
		ADD	ESI,4
		MOV	EDI,OFF SYMBOL_TEXT
		REPE	CMPSB
		JZ	MS_MATCHED
		ADD	ESI,ECX		;ADJUST SI FOR NEXT TOKEN
		CMP	BPTR [EDI-1],CH	;DID WE REACH END OF TOKEN?
		JNZ	MS_CHECK_NEXT	;NO, TRY NEXT
		INC	ECX
		SUB	DL,CL
		CMP	DL,BL		;IS IT AT LEAST MINMATCH LONG?
		JC	MS_CHECK_NEXT
MS_EXEC_THIS:
		CALL	DPTR [EAX]
		SLASH_FOUND = 0xFF;
		JMP	L1$

MS_MATCHED:
		CMP	[EDI],CL
		JNZ	MS_CHECK_NEXT
		JMP	MS_EXEC_THIS

TRY_?:
		CMP	AL,'?'-'A'
		JNZ	MS_BAD_CMD
		JMP	MS_HELP

MS_BAD_CMD:
		;
		;SKIP TO END OF COMMAND...
		;
		MOV	AL,CMDLIN_ERR
		CALL	WARN_SYMBOL_TEXT_RET
		JMP	L1$

GETNST_SLASH	ENDP


PARSE_OUTFILE	PROC	NEAR
		;
		;GET NAME OF OUTPUT FILE (USE FIRST OBJ AS DEFAULT)
		;
		MOV	FILESTUFF_PTR,OFF EXESTUFF
L1$:
		CALL	GETNST_SLASH
		CMP	AL,'+'
		JZ	L1$			;YEA, SKIP THOSE
		CMP	AL,','
		JZ	L6$			;GOT A COMMA
		CMP	AL,0DH
		JZ	L7$
L2$:
		DEC	INPTR1
L3$:
		MOV	EAX,OFF EXESTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM

		push	ECX
		mov	ECX,ESP
		push	ECX
		push	EAX
		call	_filename_install
		add	ESP,8
		pop	ECX
		;CALL	FILENAME_INSTALL	;EAX IS GINDEX, ECX IS FILE_LIST PHYS
		ASSUME	ECX:PTR FILE_LIST_STRUCT

		OR	[ECX].FILE_LIST_FLAGS,MASK FLF_RANDOM
		CALL	INSTALL_OUTFILE
		ASSUME	ECX:NOTHING

		MOV	_OUTFILE_GINDEX,EAX

		MOV	EAX,OFF FILNAM
		push	EAX
		call	_check_nul
		add	ESP,4
		MOV	EAX,OFF FILNAM
		TEST	[EAX].NFN_STRUCT.NFN_FLAGS,MASK NFN_NUL
		JNZ	L5$
		push	EAX
		call	_do_srcnam
		add	ESP,4
L5$:
		;
		;(SE) Test for .DLL output (to avoid .def file)
		;
		MOV	EAX,OFF FILNAM
		ASSUME	EAX:PTR NFN_STRUCT

		CMP	[EAX].NFN_EXTLEN,4
		JNE	L51$

		MOV	ECX,[EAX].NFN_TOTAL_LENGTH

		LEA	ECX,[EAX+ECX].NFN_TEXT

		MOV	ECX,[ECX-4]

		OR	ECX,20202000h

		CMP	ECX,'lld.'
		JNE	L51$

		ASSUME	EAX:NOTHING
		OR	FLAG_0C,MASK APPTYPE		;OUTPUT A LIBRARY
L51$:
		CALL	GETNST_SLASH
		CMP	AL,'+'
		JZ	L5$			;SKIP ANY TRAILING +'S
		CMP	AL,0DH
		JZ	L9$
		CMP	AL,','
		JNZ	L8$
		;
		;MAKE SURE DEFAULT USED FOR MAP FILE
		;
		MAPFILE_SELECTED = 0xFF;
		JMP	L9$

L8$:
		DEC	INPTR1
L9$:
		MOV	LAST_DELIM,AL
		RET

L6$:
		;
		;GOT A COMMA, SKIP IT IF WE JUST HAD A CR
		;
		CMP	LAST_DELIM,0DH
		JZ	L3$
		JMP	L2$

L7$:
		;
		;GOT A CR, SKIP IT IF WE JUST HAD A COMMA
		;
		CMP	LAST_DELIM,','
		JZ	L3$
		JMP	L2$

PARSE_OUTFILE	ENDP


PARSE_MAPFILE	PROC	NEAR
		;
		;GET NAME OF MAP FILE (USE OUTFILE AS DEFAULT IF SELECTED)
		;
		MOV	FILESTUFF_PTR,OFF MAPSTUFF
L1$:
		CALL	GETNST_SLASH
		CMP	AL,'+'
		JZ	L1$		;SKIP ANY LEADING +'S
		CMP	AL,','
		JZ	L6$
		CMP	AL,0DH
		JZ	L7$
L2$:
		DEC	INPTR1
L3$:
		MOV	EAX,OFF MAPSTUFF
		CALL	YYLEX_FILENAME
		SKIP_OUTFILE_LINK = 0xFF;
		MOV	EAX,OFF FILNAM
		push	ECX
		mov	ECX,ESP
		push	ECX
		push	EAX
		call	_filename_install
		add	ESP,8
		pop	ECX
		;CALL	FILENAME_INSTALL	;EAX IS GINDEX, ECX IS FILE_LIST PHYS

		CALL	INSTALL_OUTFILE		;THIS IS AN OUTPUT FILE

		MOV	MAPFILE_GINDEX,EAX
		XOR	ECX,ECX
		MOV	EAX,OFF FILNAM
		SKIP_OUTFILE_LINK,CL = 0;
		MAPFILE_SELECTED,CL = 0;
		CMP	[EAX].NFN_STRUCT.NFN_PRIMLEN,ECX
		JZ	L5$
		push	EAX
		call	_check_nul
		add	ESP,4
		MOV	EAX,OFF FILNAM
		TEST	[EAX].NFN_STRUCT.NFN_FLAGS,MASK NFN_NUL
		JNZ	L5$
		MAPFILE_SELECTED = 0xFF;
		SEGMENTS_MAP = 0xFF;
L5$:
		CALL	GETNST_SLASH
		CMP	AL,'+'
		JZ	L5$			;SKIP ANY TRAILING +'S
		CMP	AL,0DH
		JZ	L9$
		CMP	AL,','
		JZ	L9$
L8$:
		DEC	INPTR1
L9$:
		MOV	LAST_DELIM,AL
		RET

L6$:
		;
		;GOT A COMMA, SKIP IT IF WE JUST HAD A CR
		;
		CMP	LAST_DELIM,0DH
		JZ	L3$
		JMP	L2$

L7$:
		;
		;GOT A CR, SKIP IT IF WE JUST HAD A COMMA
		;
		CMP	LAST_DELIM,','
		JZ	L3$
		JMP	L2$

PARSE_MAPFILE	ENDP


PARSE_DEFFILE	PROC	NEAR
		;
		;GET NAME OF MAP FILE (USE OUTFILE AS DEFAULT IF SELECTED)
		;
		MOV	FILESTUFF_PTR,OFF DEFSTUFF
L1$:
		CALL	GETNST_SLASH
		CMP	AL,'+'
		JZ	L1$			;SKIP ANY LEADING +'S
if	fg_def
		CMP	AL,','
		JZ	L6$
		CMP	AL,0DH
		JZ	L7$
L2$:
		DEC	INPTR1
L3$:
		MOV	EAX,OFF DEFSTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM

		push	EAX
		call	_store_filnam
		add	ESP,4

		XOR	ECX,ECX
		MOV	DEFFILE,EAX
		MOV	EAX,OFF FILNAM
		DEFFILE_SELECTED,CL = 0;
		CMP	[EAX].NFN_STRUCT.NFN_PRIMLEN,ECX
		JZ	L5$
		push	EAX
		call	_check_nul
		add	ESP,4
		MOV	EAX,OFF FILNAM
		TEST	[EAX].NFN_STRUCT.NFN_FLAGS,MASK NFN_NUL
		JNZ	L5$
		DEFFILE_SELECTED = 0xFF;
L5$:
		CALL	GETNST_SLASH
		CMP	AL,'+'
		JZ	L5$			;SKIP ANY TRAILING +'S
		CMP	AL,','
		JZ	L9$
		CMP	AL,0DH
		JZ	L9$
		DEC	INPTR1
L9$:
endif
		MOV	LAST_DELIM,AL
		RET

if	fg_def

L6$:
		;
		;GOT A COMMA, SKIP IT IF WE JUST HAD A CR
		;
		CMP	LAST_DELIM,0DH
		JZ	L3$
		JMP	L2$

L7$:
		;
		;GOT A CR, SKIP IT IF WE JUST HAD A COMMA
		;
		CMP	LAST_DELIM,','
		JZ	L3$
		JMP	L2$

endif

PARSE_DEFFILE	ENDP


PARSE_LIBS	PROC	NEAR
		;
		;GET NAMES OF LIBRARIES TO SEARCH
		;
		MOV	FILESTUFF_PTR,OFF LIBSTUFF
L1$:
		CALL	GETNST_SLASH
		CMP	AL,','
		JZ	L6$			;SKIP COMMA
		CMP	AL,0DH
		JZ	L4$			;TERMINATE IF PLUS NOT FOUND
		MOV	LAST_DELIM,0
		CMP	AL,'+'
		JZ	L3$			;FLAG + FOUND
		DEC	INPTR1
		CMP	AL,';'
		JZ	L9$
		CMP	AL,1AH
		JZ	L9$
		PLUS_FOUND = 0;
		MOV	EAX,OFF LIBSTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM
		CALL	HANDLE_LIBS
		JMP	L1$

L3$:
		PLUS_FOUND = 0xFF;
		JMP	L1$

L6$:
		;
		;COMMA FOUND
		;
		CMP	LAST_DELIM,0DH
		JMP	L41$

L4$:
		;
		;CR FOUND
		;
		CMP	LAST_DELIM,','
L41$:
		MOV	LAST_DELIM,0
		JNZ	L45$
		JMP	L1$

L45$:
		MOV	LAST_DELIM,AL
		BITT	PLUS_FOUND
		PUSHFD
		PLUS_FOUND = 0;
		POPFD
		JZ	L71$
		JMP	L1$

L71$:
		RET

L9$:
		PLUS_FOUND = 0;
		RET

PARSE_LIBS	ENDP


PARSE_RCS	PROC	NEAR
		;
		;GET NAMES OF .RES FILES TO BIND
		;
		MOV	FILESTUFF_PTR,OFF RESSTUFF
L1$:
		CALL	GETNST_SLASH
		CMP	AL,','
		JZ	L6$			;SKIP COMMA
		CMP	AL,0DH
		JZ	L4$			;TERMINATE IF PLUS NOT FOUND
		MOV	LAST_DELIM,0
		CMP	AL,'+'
		JZ	L3$			;FLAG + FOUND
		DEC	INPTR1
		CMP	AL,';'
		JZ	L9$
		CMP	AL,1AH
		JZ	L9$
		PLUS_FOUND = 0;
		RC_SUPPLIED = 0xFF;
		MOV	EAX,OFF RESSTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM
		CALL	HANDLE_RCS
		JMP	L1$

L3$:
		PLUS_FOUND = 0xFF;
		JMP	L1$

L6$:
		;
		;COMMA FOUND
		;
		CMP	LAST_DELIM,0DH
		JMP	L41$

L4$:
		;
		;CR FOUND
		;
		CMP	LAST_DELIM,','
L41$:
		MOV	LAST_DELIM,0
		JNZ	L45$
		JMP	L1$

L45$:
		MOV	LAST_DELIM,AL
		BITT	PLUS_FOUND
		PUSHFD
		PLUS_FOUND = 0;
		POPFD
		JZ	L71$
		JMP	L1$

L71$:
		RET

L9$:
		PLUS_FOUND = 0;
		RET

PARSE_RCS	ENDP


MAKE_MAPOUT	PROC
		;
		PUSHM	EDI,ESI
		MAPFILE_SELECTED = 0xFF;
		SYMBOLS_OUT = 0xFF;
L1$:
		CALL	FIX_GET_COLON
		JNZ	L3$
		CALL	GET_KEYWORD
		MOV	EAX,SYMBOL_LENGTH	;AT LEAST THIS MANY MUST MATCH
		MOV	ESI,OFF FULL_TEXT
		MOV	ECX,EAX
		MOV	EDI,OFF SYMBOL_TEXT
		TEST	ECX,ECX
		MOV	EDX,EDI
		JZ	L4$
		REPE	CMPSB
		JNZ	L5$
		DETAILEDMAP_FLAG = 0xFF;
		ALPHA_ORDER_ALSO = 0xFF;
		JMP	L1$

L3$:
		POPM	ESI,EDI
		RET

L4$:
		POPM	ESI,EDI
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		RET

L5$:
		MOV	ECX,EAX			;AT LEAST THIS MANY MUST MATCH
		MOV	EDI,EDX
		MOV	ESI,OFF ADDRESS_TEXT
		REPE	CMPSB
		JNZ	L51$
		ALPHA_ORDER_ALSO = 0;
		JMP	L1$

L51$:
		MOV	ECX,EAX			;AT LEAST THIS MANY MUST MATCH
		MOV	EDI,EDX
		MOV	ESI,OFF GROUP_TEXT
		REPE	CMPSB
		JNZ	L52$
		PRINT_GROUP = 0xFF;
		JMP	L1$

L52$:
		MOV	ECX,EAX			;AT LEAST THIS MANY MUST MATCH
		MOV	EDI,EDX
		MOV	ESI,OFF NOGROUP_TEXT
		REPE	CMPSB
		JNZ	L53$
		PRINT_GROUP = 0;
		JMP	L1$

L53$:
L59$:
		CALL	GET_NUMBER1
		TEST	EAX,EAX
		JNZ	L6$
		ALPHA_ORDER_ALSO = 0;
L6$:
		JMP	L1$

MAKE_MAPOUT	ENDP


GET_NUMBER	PROC
		;
		;MS FORMAT NUMBER
		;
		CALL	GET_KEYWORD

GET_NUMBER1	LABEL	PROC

		PUSHM	ESI,EBX
		MOV	ESI,OFF SYMBOL_TEXT
		XOR	EAX,EAX
		XOR	EBX,EBX
		XOR	ECX,ECX
		MOV	BL,[ESI]
		MOV	ECX,10
		SUB	BL,30H
		INC	ESI
		CMP	BL,CL
		JA	GN_ERROR
		OR	BL,BL
		JNZ	GET_DECIMAL
		MOV	BL,[ESI]
		INC	ESI
		MOV	CL,8
		CMP	BL,'X'
		JZ	GET_HEX
		CMP	BL,'x'
		JNZ	GET_OCTAL
GET_HEX:
		MOV	CL,16
G_LOOP:
		MOV	BL,[ESI]
		INC	ESI
GET_OCTAL:
		SUB	BL,30H
		CMP	BL,0AH
		JC	GET_DECIMAL
		SUB	BL,7
		CMP	BL,0AH
		JC	NUMBER_DONE
		CMP	BL,10H		;MUST BE 0A-0F
		JC	GET_DECIMAL
		CMP	BL,'a'-30H-7
		JC	NUMBER_DONE
		CMP	BL,'f'-30H-7
		JA	NUMBER_DONE
		SUB	BL,20H
GET_DECIMAL:
		CMP	BL,CL
		JNC	NUMBER_DONE

		MUL	ECX
		JC	L9$
		ADD	EAX,EBX
		JNC	G_LOOP
L9$:
GN_ERROR::
		MOV	AL,ILL_NUMBER_ERR
		CALL	ERR_SYMBOL_TEXT_ABORT

NUMBER_DONE:
		SUB	ESI,OFF SYMBOL_TEXT+1		;RESTORE CHARACTERS NOT PROCESSED
		POP	EBX
		SUB	ESI,SYMBOL_LENGTH
		ADD	INPTR1,ESI
		POP	ESI
		RET

GET_NUMBER	ENDP


GET_COLON_NUMBER16	PROC

		CALL	GET_COLON_NUMBER
		TEST	EAX,0FFFF0000H
		JNZ	GN_ERROR
		RET

GET_COLON_NUMBER16	ENDP


GET_NUMBER16	PROC

		CALL	GET_NUMBER
		TEST	EAX,0FFFF0000H
		JNZ	GN_ERROR
		RET

GET_NUMBER16	ENDP


GET_COLON_NUMBER	PROC
		;
		;
		;
		CALL	CHECK_COLON
		JMP	GET_NUMBER

GET_COLON_NUMBER	ENDP


MS_HELP		PROC
		;
		;PRINT HELP MESSAGE
		;PROCESS THROUGH OTHER TABLE...
		;
		MOV	EAX,OFF MS_CMD_PTRS
		JMP	HELP_PROC_1

MS_HELP		ENDP


SET_DEBUGALL	PROC
		;
		;
		;
		MOV	AL,-1
DBG_SET::
		OR	DEBUG_TYPES_SELECTED,AL
		RET

SET_DEBUGALL	ENDP


SET_DEBUGBROWSERDEFS	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_BROWSERDEFS
		JMP	DBG_SET

SET_DEBUGBROWSERDEFS	ENDP


SET_DEBUGBROWSERREFS	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_BROWSERREFS
		JMP	DBG_SET

SET_DEBUGBROWSERREFS	ENDP


SET_DEBUGCOVERAGES	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_COVERAGES
		JMP	DBG_SET

SET_DEBUGCOVERAGES	ENDP


SET_DEBUGLOCALS	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_LOCALS
		JMP	DBG_SET

SET_DEBUGLOCALS	ENDP


SET_DEBUGLINNUMS	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_LINNUMS
		JMP	DBG_SET

SET_DEBUGLINNUMS	ENDP


SET_DEBUGPUBLICS	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_PUBLICS
		JMP	DBG_SET

SET_DEBUGPUBLICS	ENDP


SET_DEBUGTYPES	PROC
		;
		;
		;
		MOV	AL,MASK FL_DEBUG_TYPES
		JMP	DBG_SET

SET_DEBUGTYPES	ENDP


RES_DEBUGALL	PROC
		;
		;
		;
		MOV	AL,0
DBG_CLEAR::
		AND	DEBUG_TYPES_SELECTED,AL
		FANCY_DEBUG = 0xFF;
		RET

RES_DEBUGALL	ENDP


RES_DEBUGBROWSERDEFS	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_BROWSERDEFS
		JMP	DBG_CLEAR

RES_DEBUGBROWSERDEFS	ENDP


RES_DEBUGBROWSERREFS	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_BROWSERREFS
		JMP	DBG_CLEAR

RES_DEBUGBROWSERREFS	ENDP


RES_DEBUGCOVERAGES	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_COVERAGES
		JMP	DBG_CLEAR

RES_DEBUGCOVERAGES	ENDP


RES_DEBUGLOCALS	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_LOCALS
		JMP	DBG_CLEAR

RES_DEBUGLOCALS	ENDP


RES_DEBUGLINNUMS	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_LINNUMS
		JMP	DBG_CLEAR

RES_DEBUGLINNUMS	ENDP


RES_DEBUGPUBLICS	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_PUBLICS
		JMP	DBG_CLEAR

RES_DEBUGPUBLICS	ENDP


RES_DEBUGTYPES	PROC
		;
		;
		;
		MOV	AL,NOT MASK FL_DEBUG_TYPES
		JMP	DBG_CLEAR

RES_DEBUGTYPES	ENDP


HANDLE_DEBUGFILES	PROC
		;
		;
		;
if	any_overlays
		CALL	FIX_GET_COLON
		JNZ	L9$
else
		CALL	CHECK_COLON
endif
		FANCY_DEBUG = 0xFF;
L1$:
		MOV	EAX,OFF OBJSTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM
		push	ECX
		mov	ECX,ESP
		push	ECX
		push	EAX
		call	_filename_install
		add	ESP,8
		pop	ECX
		;CALL	FILENAME_INSTALL	;THAT FILE...
		OR	[ECX].FILE_LIST_STRUCT.FILE_LIST_PLINK_FLAGS,MASK FL_DEBUG_COVERAGES+MASK FL_DEBUG_LINNUMS+MASK FL_DEBUG_LOCALS+ \
						MASK FL_DEBUG_PUBLICS+MASK FL_DEBUG_TYPES+MASK FL_DEBUG_BROWSERDEFS+ \
						MASK FL_DEBUG_BROWSERREFS
		CALL	FIX_GET_COLON
		JZ	L1$
		RET

if	any_overlays
L9$:
		DEBUG_FLAG = 0xFF;
		MOV	DEBUG_BYTE,'Y'
		RET
endif

HANDLE_DEBUGFILES	ENDP


HANDLE_DEBUGMODULES	PROC
		;
		;
		;
if	any_overlays
		CALL	FIX_GET_COLON
		JNZ	L9$
else
		CALL	CHECK_COLON
endif
		FANCY_DEBUG = 0xFF;
L1$:
		CALL	YYLEX_SYMBOL		;

		MOV	EAX,OFF SYMBOL_TPTR
		CALL	FORCE_INSTALL_MODULE	;THAT FILE...
		;
		;
		;
		OR	[ECX].MODULE_STRUCT._M_FLAGS,MASK M_DEBUG_GLOBAL
		CALL	FIX_GET_COLON
		JZ	L1$
		RET

if	any_overlays
L9$:
		DEBUG_FLAG = 0xFF;
		MOV	DEBUG_BYTE,'Y'
		RET
endif

HANDLE_DEBUGMODULES	ENDP
#endif


void _set_detailedmap()
{
    SEGMENTS_MAP = 0xFF;
    DETAILEDMAP_FLAG = 0xFF;
}

void _res_detailedmap()
{
    DETAILEDMAP_FLAG = 0;
}

void _no_make_mapout()
{
    SYMBOLS_OUT = 0;
}

void _xnoignorecase_proc()
{
    PRESERVE_IMPEXP_CASE = 0xFF;
}

void _xupper_proc()
{
    PRESERVE_IMPEXP_CASE = 0;
}

void _errorflag_proc()
{
    HANDLE_EXE_ERRORFLAG = 0xFF;
}

void _noerrorflag_proc()
{
    HANDLE_EXE_ERRORFLAG = 0;
}

#if 0

SET_ENTRYPOINT	PROC
		;
		;
		;
		CALL	CHECK_COLON

		CALL	GET_SYMBOL	;PARSE A SYMBOL (NO TRANSLATE)

		MOV	EAX,SYMBOL_LENGTH
		PUSH	EDI

		MOV	ESI,OFF SYMBOL_TEXT
		MOV	ECX,EAX

		ADD	EAX,4
		PUSH	ESI

		P1ONLY_POOL_ALLOC

		MOV	ENTRYPOINT_TXT,EAX
		MOV	[EAX],ECX

		LEA	EDI,[EAX+4]

		REP	MOVSB

		POPM	ESI,EDI

		RET

SET_ENTRYPOINT	ENDP
#endif

void _fixds_proc()
{
    FIXDS_FLAG = 0xFF;
}

void _res_fixds()
{
    FIXDS_FLAG = 0;
}

void _make_xref()
{
    XREF_OUT = 0xFF;
}

void _no_make_xref()
{
    XREF_OUT = 0;
}

#if 0
CHECK_COLON	PROC

		CALL	FIX_GET_COLON
		JNZ	COLON_EXP
		RET

COLON_EXP	LABEL	PROC

		MOV	AL,MISSING_COLON_ERR
		JMP	ERR_SYMBOL_TEXT_ABORT

CHECK_COLON	ENDP
#endif

void _set_abort_chk()
{
    ABORT_ON_CHECKSUM = 0xFF;
}

void _res_abort_chk()
{
    ABORT_ON_CHECKSUM = 0;
}

void _enable_checkexe()
{
    // CHECKSUM_EXE_FLAG = 0xFF;
}

void _disable_checkexe()
{
    // CHECKSUM_EXE_FLAG = 0;
}

void _set_pause()
{
    PAUSE_FLAG = 0xFF;
}

void _res_pause()
{
    PAUSE_FLAG = 0;
}

void _set_prompt_mode()
{
    CMDLINE_FINAL = 0;
}

void _res_prompt_mode()
{
    CMDLINE_FINAL = 0xFF;
}

#if 0
ONERROR_PROC	PROC
		;
		;ONERROR:NOEXE
		;
		CALL	CHECK_COLON	;MUST HAVE A COLON
		CALL	GET_KEYWORD	;DOES UPPERCASE
		PUSHM	EDI,ESI

		MOV	EAX,SYMBOL_LENGTH
		MOV	EDI,OFF NOEXE_TXT
		TEST	EAX,EAX
		JZ	L9$
		MOV	ECX,EAX
		MOV	ESI,OFF SYMBOL_TEXT
		REPE	CMPSB		;CX BYTES MUST MATCH
		JNZ	L9$
		CALL	ERRORDELETE_PROC
		POPM	ESI,EDI
		RET

L9$:
		POPM	ESI,EDI
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		RET

ONERROR_PROC	ENDP


if	fg_segm

PMTYPE_PROC	PROC
		;
		;PMTYPE:[PM | VIO | NOVIO]
		;
		CALL	CHECK_COLON	;MUST HAVE A COLON
		CALL	GET_KEYWORD
		PUSHM	EDI,ESI,EBX

		MOV	EBX,OFF PM_TYPES
		MOV	EDX,3		;3 TYPES TO CHECK
L1$:
		MOV	ESI,[EBX]
		MOV	ECX,SYMBOL_LENGTH;AT LEAST THIS MANY MUST MATCH
		MOV	EDI,OFF SYMBOL_TEXT
		TEST	ECX,ECX
		JZ	L4$
		REPE	CMPSB
		MOV	EAX,[EBX+4]
		JZ	L5$
		ADD	EBX,8
		DEC	EDX
		JNZ	L1$
L4$:
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		POPM	EBX,ESI,EDI
		RET

L5$:
		POPM	EBX,ESI,EDI
		OR	FLAG_0C,EAX
		RET

PMTYPE_PROC	ENDP

endif


EXETYPE_PROC	PROC
		;
		;EXETYPE:[OS2 | WINDOWS | DOS4 | UNKNOWN | DOS | NT | DOSX]
		;
		CALL	CHECK_COLON	;MUST HAVE A COLON
		CALL	GET_KEYWORD
		PUSHM	EDI,ESI,EBX
		MOV	EBX,OFF EXE_TYPES
		MOV	EDX,N_EXE_TYPES	;6 TYPES TO CHECK
L1$:
		MOV	ESI,[EBX]
		MOV	ECX,SYMBOL_LENGTH;AT LEAST THIS MANY MUST MATCH
		MOV	EDI,OFF SYMBOL_TEXT
		TEST	ECX,ECX
		JZ	L4$
		REPE	CMPSB
		MOV	EAX,[EBX+4]
		JZ	L5$
		ADD	EBX,8
		DEC	EDX
		JNZ	L1$
L4$:
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		POPM	EBX,ESI,EDI
		RET

L5$:
		POPM	EBX,ESI,EDI
		MOV	EXETYPE_CMDLINE_FLAG,AL
		RET

EXETYPE_PROC	ENDP


SUBSYSTEM_PROC	PROC
		;
		;SUBSYSTEM:[OS2 | WINDOWS | DOS4 | UNKNOWN | DOS | NT | DOSX]
		;
		CALL	CHECK_COLON	;MUST HAVE A COLON
		CALL	GET_KEYWORD

		PUSHM	EDI,ESI,EBX
		MOV	EBX,OFF SUBSYS_TYPES
		MOV	EDX,N_SUBSYS_TYPES	;6 TYPES TO CHECK
L1$:
		MOV	ESI,[EBX]
		MOV	ECX,SYMBOL_LENGTH	;AT LEAST THIS MANY MUST MATCH
		MOV	EDI,OFF SYMBOL_TEXT
		TEST	ECX,ECX
		JZ	L4$

		REPE	CMPSB

		MOV	EAX,[EBX+4]
		JZ	L5$

		ADD	EBX,8
		DEC	EDX
		JNZ	L1$
L4$:
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		POPM	EBX,ESI,EDI
		RET

L5$:
		CALL	SET_SUBSYSTEM

		JNZ	L4$

		CALL	FIX_GET_COLON

		JNZ	L9$

		CALL	GET_NUM_DOT_NUM

		MOV	ECX,EDX
		CALL	SET_SUBSYS_VERSION

		JNZ	L4$
L9$:
		POPM	EBX,ESI,EDI

		RET

SUBSYSTEM_PROC	ENDP


FIX_GET_COLON	PROC
		;
		;
		;
		CALL	GETNST
		CMP	AL,':'
		JZ	L9$
		DEC	INPTR1
L9$:
		RET

FIX_GET_COLON	ENDP
#endif

void _set_ems_io_legal()
{
    EMS_IO_LEGAL = 0xFF;
}

void _res_ems_io_legal()
{
    EMS_IO_LEGAL = 0;
}

#if 0
SET_EMSMAXSIZE	PROC
		;
		CALL	GET_COLON_NUMBER16
;		MOV	EMS_MAX_1K_BLOCKS,AX
		RET

SET_EMSMAXSIZE	ENDP


SET_XMSMAXSIZE	PROC
		;
		CALL	GET_COLON_NUMBER16
;		MOV	XMS_MAX_1K_BLOCKS,AX
		RET

SET_XMSMAXSIZE	ENDP
#endif

void _set_emsuse40()
{
    FORCE_EMS_32 = 0;
}

void _res_emsuse40()
{
    FORCE_EMS_32 = 0xFF;
}

#if 0
SET_EXEPACK	PROC
		;
		;
		;
		EXEPACK_SELECTED = 0xFF;
SET_EXEPACK_1	LABEL	PROC

		CALL	FIX_GET_COLON
		JZ	L1$
		RET

L1$:
		CALL	GET_NUMBER
		INC	EAX			;FORCE TO # OF WORDS...
		AND	AL,0FEH
		CMP	DONT_PACK,EAX
		JA	L2$
		MOV	DONT_PACK,EAX
L2$:
		RET

SET_EXEPACK	ENDP
#endif


void _res_exepack()
{
    EXEPACK_SELECTED = 0;
}

#if 0
if	fg_winpack

SET_WINPACK	PROC
		;
		;
		;
if	fg_virt AND (NOT debug)
		MOV	AL,CANT_WINPACK_ERR
		push	EAX
		call	_err_abort
else
		WINPACK_SELECTED = 0xFF;
endif

SET_WINPACK	ENDP
#endif


void _set_segpack()
{
    SEGPACK_SELECTED = 0xFF;
}

void _res_winpack()
{
    WINPACK_SELECTED = 0;
    SEGPACK_SELECTED = 0;
}

void _set_debugapploader()
{
    WINPACK_LICENSED = 0;
}

void _res_debugapploader()
{
    WINPACK_LICENSED = 0xFF;
}

//void _set_extdictionary()
//{
//    EXTDICTIONARY_FLAG = 0xFF;
//}

void _res_extdictionary()
{
    //EXTDICTIONARY_FLAG = 0;
}

void _set_largeaddressaware()
{
    PE_LARGE_ADDRESS_AWARE = 0xFF;
}

void _set_linenumbers()
{
    MAPFILE_SELECTED = 0xFF;
    LINENUMBERS_FLAG = 0xFF;
}

void _res_linenumbers()
{
    LINENUMBERS_FLAG = 0;
}

void _set_defaultlibrarysearch()
{
    DEFAULTLIBRARYSEARCH_FLAG = 0xFF;
}

#if 0
RES_DEFAULTLIBRARYSEARCH	PROC
		;
		;
		;
		CALL	FIX_GET_COLON
		JZ	L1$
		DEFAULTLIBRARYSEARCH_FLAG = 0;
		RET

L1$:
		;
		;NEED TO DISABLE A SINGLE LIBRARY NAME...
		;OK,
		;
		DOING_NODEF = 0xFF;
		MOV	EAX,OFF LIBSTUFF
		CALL	YYLEX_FILENAME		;NOW, WAS A PATH SUPPLIED?
		MOV	EAX,OFF FILNAM
		push	EAX
		call	_do_search_library
		add	ESP,4
		DOING_NODEF = 0;
		RET

RES_DEFAULTLIBRARYSEARCH	ENDP


if	fg_segm OR fg_pe

RC_PROC		PROC
		;
		;HANDLE SUPPLYING AN RC FILE FOR INCLUSION...
		;
		BITT	RC_SUPPLIED
		JNZ	L0$
		RC_SUPPLIED = 0xFF;
		RC_REORDER = 0xFF;
		OR	FLAG_0C,MASK APPWINFLAGS
L0$:
		CALL	FIX_GET_COLON
		JZ	L1$
		CMP	AL,'-'
		JZ	L2$
		RET

L9$:
		MOV	AL,MULTIPLE_RC_ERR
		push	EAX
		call	_err_abort

L1$:
		MOV	EAX,OFF RCSTUFF
		CALL	YYLEX_FILENAME
		MOV	EAX,OFF FILNAM
		CALL	HANDLE_RCS
		JMP	L0$

L2$:
		INC	INPTR1
		CALL	GET_KEYWORD
		MOV	ECX,SYMBOL_LENGTH
		MOV	EAX,DPTR SYMBOL_TEXT
		DEC	ECX
		JNZ	L25$
		CMP	AL,'a'
		JC	L11$
		CMP	AL,'z'
		JA	L11$
		SUB	AL,20H
L11$:
		CMP	AL,'E'
		MOV	EBX,MASK APP386			;DRIVER USES EMS
		JZ	L19$
		CMP	AL,'L'
		MOV	EBX,MASK APP86			;APP USES EMS
		JZ	L19$
		CMP	AL,'M'
		MOV	EBX,MASK APP286			;MULTIPLE INSTANCE (MORE EMS JUNK)
		JZ	L19$
		CMP	AL,'P'
		MOV	EBX,MASK APP??			;PRIVATE LIBRARY
		JZ	L19$
		CMP	AL,'T'				;PROTMODE ONLY
		JZ	L16$
		CMP	AL,'K'
		JNZ	L95$
		RC_REORDER = 0;
		JMP	L0$

L16$:
		CALL	RC_PROTMODE
		JMP	L0$

L19$:
		OR	FLAG_0C,EBX
		JMP	L0$

L95$:
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		RET

L25$:
		DEC	ECX
		JNZ	L95$
		CMP	AX,'04'
		MOV	EBX,400H
		JZ	L27$
		CMP	AX,'03'
		MOV	BH,3
		JZ	L27$
		CMP	AX,'13'
		JNZ	L95$
		MOV	BL,0AH
L27$:
		BITT	WINVER_SELECTED
		JNZ	L28$
		MOV	NEXEHEADER._NEXE_WINVER_INT,BH
		WINVER_SELECTED = 0xFF;
		MOV	NEXEHEADER._NEXE_WINVER_FRAC,BL
L28$:
		JMP	L0$

RC_PROC		ENDP


STUB_PROC	PROC
		;
		;HANDLE SUPPLYING A STUB FILE FOR INCLUSION...
		;
		CALL	CHECK_COLON

		MOV	EAX,OFF STUBSTUFF
		CALL	YYLEX_FILENAME

		BITT	STUB_SUPPLIED
		JNZ	L9$
		BITT	STUB_NONE
		JNZ	L9$

		MOV	EAX,OFF FILNAM.NFN_TEXT

		ADD	EAX,FILNAM.NFN_PATHLEN

		MOV	EAX,[EAX]

		CMP	EAX,'ENON'
		JZ	L5$

		CMP	EAX,'enon'
		JZ	L5$

		STUB_SUPPLIED = 0xFF;

		MOV	EAX,OFF FILNAM
		JMP	HANDLE_STUB

L5$:
		STUB_NONE = 0xFF;
		RET

L9$:
		MOV	AL,DUP_STUB_ERR
		JMP	ERR_INBUF_RET

STUB_PROC	ENDP


if	V5

		PUBLIC	PARSE_IMPDEF_FILENAME,PARSE_IMPLIB_FILENAME,PARSE_IMPLIB_COFF_FILENAME

SET_IMPDEF	PROC
		;
		;POSSIBLY :FILENAME, .DIN OUTPUT DESCRIBING THIS .DLL
		;
		IMPDEF_FLAG = 0xFF;			// HE WANTS US TO BUILD .DIN
		CALL	FIX_GET_COLON
		JZ	L1$
		RET

L1$:
		CALL	PARSE_IMPDEF_FILENAME
		RET

SET_IMPDEF	ENDP


PARSE_IMPDEF_FILENAME	PROC
		;
		;
		;
		MOV	EAX,OFF IMPDEF_STUFF	;LIKE DEF, BUT USE PRIMARY NAME AS DEFAULT
		CALL	YYLEX_FILENAME
		SKIP_OUTFILE_LINK = 0xFF;
		MOV	EAX,OFF FILNAM
		push	ECX
		mov	ECX,ESP
		push	ECX
		push	EAX
		call	_filename_install
		add	ESP,8
		pop	ECX
		;CALL	FILENAME_INSTALL	;AX IS GINDEX, DS:BX IS FILE_LIST PHYS

		CALL	INSTALL_OUTFILE		;THIS IS AN OUTPUT FILE
		MOV	IMPDEF_FILE_GINDEX,EAX
		SKIP_OUTFILE_LINK = 0;
		RET

PARSE_IMPDEF_FILENAME	ENDP


SET_IMPLIB	PROC
		;
		;POSSIBLY :FILENAME, .LIB OUTPUT DESCRIBING THIS .DLL
		;
		IMPLIB_FLAG = 0xFF;			// HE WANTS US TO BUILD .LIB
		CALL	FIX_GET_COLON
		JZ	L1$
		RET

L1$:
		CALL	PARSE_IMPLIB_FILENAME
		RET

SET_IMPLIB	ENDP


PARSE_IMPLIB_FILENAME	PROC
		;
		;
		;
		MOV	EAX,OFF IMPLIB_STUFF	;LIKE LIB, BUT USE PRIMARY NAME AS DEFAULT
		CALL	YYLEX_FILENAME
		SKIP_OUTFILE_LINK = 0xFF;
		MOV	EAX,OFF FILNAM
		push	ECX
		mov	ECX,ESP
		push	ECX
		push	EAX
		call	_filename_install
		add	ESP,8
		pop	ECX
		;CALL	FILENAME_INSTALL	;AX IS GINDEX, DS:BX IS FILE_LIST PHYS
		CALL	INSTALL_OUTFILE		;THIS IS AN OUTPUT FILE
		MOV	IMPLIB_FILE_GINDEX,EAX
		SKIP_OUTFILE_LINK = 0;
		RET

PARSE_IMPLIB_FILENAME	ENDP

SET_IMPLIB_COFF	PROC
		;
		;POSSIBLY :FILENAME, .LIB OUTPUT DESCRIBING THIS .DLL
		;
		IMPLIB_COFF_FLAG = 0xFF;		// HE WANTS US TO BUILD .LIB
		CALL	FIX_GET_COLON
		JZ	L1$
		RET

L1$:
		CALL	PARSE_IMPLIB_COFF_FILENAME
		RET

SET_IMPLIB_COFF	ENDP

PARSE_IMPLIB_COFF_FILENAME PROC

		MOV	EAX,OFF IMPLIB_STUFF	;LIKE LIB, BUT USE PRIMARY NAME AS DEFAULT
		CALL	YYLEX_FILENAME
		SKIP_OUTFILE_LINK = 0xFF;
		MOV	EAX,OFF FILNAM
		push	ECX
		mov	ECX,ESP
		push	ECX
		push	EAX
		call	_filename_install
		add	ESP,8
		pop	ECX
		;CALL	FILENAME_INSTALL	;AX IS GINDEX, DS:BX IS FILE_LIST PHYS
		CALL	INSTALL_OUTFILE		;THIS IS AN OUTPUT FILE
		MOV	IMPLIB_COFF_FILE_GINDEX,EAX
		SKIP_OUTFILE_LINK = 0;
		RET

PARSE_IMPLIB_COFF_FILENAME	ENDP



SET_PAGESIZE	PROC
		;
		;:nnn, SETS PAGESIZE FOR OPTIMP .LIB FILE
		;
		CALL	GET_COLON_NUMBER16

		MOV	IMPLIB_PAGESIZE,EAX

		RET

SET_PAGESIZE	ENDP

endif

endif

SET_CPARMAXALLOC	PROC

		CALL	GET_COLON_NUMBER16
		MOV	EXEHEADER._EXE_MAX_ABOVE,AX
		RET

SET_CPARMAXALLOC	ENDP

if	any_overlays
SET_OVERLAYINTERRUPT	PROC

		CALL	GET_COLON_NUMBER16
		MOV	OVERLAY_INTERRUPT_NUMBER,EAX
		RET

SET_OVERLAYINTERRUPT	ENDP
endif
#endif

void _set_optlink()
{
}

void _set_nodosseg()
{
    NODOSSEG_FLAG = 0xFF;
}

void _set_groupassociation()
{
    GROUPASSOCIATION_FLAG = 0xFF;
}

void _res_groupassociation()
{
    GROUPASSOCIATION_FLAG = 0;
}

#if 0
SET_CODEVIEW	PROC
if	fg_cv
		CODEVIEW_FLAG = 0xFF;
if	any_overlays
		MOV	CODEVIEW_BYTE,'Y'
endif
		CALL	FIX_GET_COLON
		JNZ	L9$
		CALL	GET_NUMBER16
		MOV	CV_INFO_TYPE,AL
L9$:
endif
		RET

SET_CODEVIEW	ENDP


SET_CVVERSION	PROC
		;
		;
		;
		CALL	FIX_GET_COLON
		JNZ	L9$
		CALL	GET_NUMBER16
		MOV	CV_INFO_TYPE,AL
L9$:
		RET

SET_CVVERSION	ENDP
#endif

void _set_cvwarnings()
{
    CV_WARNINGS = 0xFF;
}

void _res_codeview()
{
    CODEVIEW_FLAG = 0;
#if	any_overlays
    CODEVIEW_BYTE = 'N';
#endif
}

void _res_cvpack()
{
    CVPACK_FLAG = 0;
}

void _set_comdef_search()
{
    COMDEF_SEARCH = 0xFF;
}

void _res_comdef_search()
{
    COMDEF_SEARCH = 0;
}

void _set_td()
{
    _res_codeview();
}

void _res_td()
{
}

void _batch_proc()
{
    // ABORT ON FILE-NOT-FOUND
    BATCH_FLAG = 0xFF;
    _res_prompt_mode();
}

void _res_batch()
{
    BATCH_FLAG = 0;
    _set_prompt_mode();
}

#if 0
SET_BINARY	PROC
		;
		OUTPUT_COM_SYS = 0xFF;
		OUTPUT_SYS = 0xFF;
		XOR	EAX,EAX
		PUSH	EAX
		CALL	FIX_GET_COLON
		POP	EAX
		JNZ	SB_DONE
		CALL	GET_NUMBER

SB_DONE		LABEL	PROC

		MOV	SYS_BASE,EAX
		RET


SET_TINY	LABEL	PROC

		OUTPUT_COM_SYS = 0xFF;
		OUTPUT_COM = 0xFF;
		MOV	EAX,100H
		JMP	SB_DONE

SET_BINARY	ENDP
#endif

void _set_relocation_check()
{
    CHECK_RELOCATIONS = 0xFF;
}

void _res_relocation_check()
{
    CHECK_RELOCATIONS = 0;
}

void _set_farcalltranslation()
{
    NOFARCALLTRANSLATION_FLAG = 0;
    FARCALLTRANSLATION_FLAG = 0xFF;
}

void _res_farcalltranslation()
{
    NOFARCALLTRANSLATION_FLAG = 0xFF;
    FARCALLTRANSLATION_FLAG = 0;
}

#if 0
SET_PACKCODE	PROC

		NOPACKCODE_FLAG = 0;
		PACKCODE_FLAG = 0xFF;
		MOV	EAX,OFF PACKCODE
		JMP	PACK_PROC

SET_PACKCODE	ENDP
#endif

void _res_packcode()
{
    PACKCODE_FLAG = 0;
    NOPACKCODE_FLAG = 0xFF;
}

#if 0
void _set_packdata()
{
		NOPACKDATA_FLAG = 0;
		PACKDATA_FLAG = 0xFF;
		MOV	EAX,OFF PACKDATA

PACK_PROC	LABEL	PROC

		PUSH	EAX
		CALL	FIX_GET_COLON
		JZ	L1$
		MOV	EAX,PACK_DEFAULT_SIZE
		JMP	L3$

L1$:
		CALL	GET_NUMBER		;EAX
		CMP	EAX,64K
		JA	GN_ERROR
		TEST	EAX,EAX
		JNZ	L3$
		MOV	EAX,64K
L3$:
		POP	ECX
		MOV	DPTR [ECX],EAX
		RET

SET_PACKDATA	ENDP
#endif

void _res_packdata()
{
    PACKDATA_FLAG = 0;
    NOPACKDATA_FLAG = 0xFF;
}

#if 0
PACKSIZE_PROC	PROC
		;
		;
		;
		CALL	GET_COLON_NUMBER16
		TEST	EAX,EAX
		JNZ	L1$
		MOV	EAX,64K
L1$:
		MOV	PACK_DEFAULT_SIZE,EAX
		RET

PACKSIZE_PROC	ENDP
#endif

void _set_packcode_no_segments()
{
    PACKCODE_NO_SEGMENTS = 0xFF;
}

void _res_packcode_no_segments()
{
    PACKCODE_NO_SEGMENTS = 0;
}

void _set_nthost()
{
    NT_HOST_FLAG = 0xFF;
}

void _res_nthost()
{
    NT_HOST_FLAG = 0;
}

#if 0
SET_NULLSDOSSEG	PROC
		;
		NULLSDOSSEG_FLAG = 0xFF;
		CALL	DOSSEG_PROC
		RET

SET_NULLSDOSSEG	ENDP
#endif


void _set_scanlib()
{
    SCAN_LIB_ENVIRONMENT = 0xFF;
}

void _res_scanlib()
{
    SCAN_LIB_ENVIRONMENT = 0;
}

void _set_scanlink()
{
    SCAN_LINK_ENVIRONMENT = 0xFF;
}

void _res_scanlink()
{
    SCAN_LINK_ENVIRONMENT = 0;
}

void _set_warnfixup()
{
    WARNFIXUP = 0xFF;
}

void _set_warndups()
{
    WARN_LIB_DUPS = 0xFF;
}

void _res_warndups()
{
    WARN_LIB_DUPS = 0;
}

#if 0
if	fg_segm OR fg_pe

SET_PADDATA	PROC
		;
		CALL	GET_COLON_NUMBER16
		MOV	PADDATA,EAX
		RET

SET_PADDATA	ENDP


SET_PADCODE	PROC
		;
		CALL	GET_COLON_NUMBER16
		MOV	PADCODE,EAX
		RET

SET_PADCODE	ENDP

endif


SET_STACK	PROC
		;
		CALL	GET_COLON_NUMBER
		CALL	SET_STACK_1
		;
if	fg_pe
		CALL	FIX_GET_COLON
		JNZ	L9$
		CALL	GET_NUMBER
		MOV	PEXEHEADER._PEXE_STACK_COMMIT,EAX
endif

L9$:
		RET

SET_STACK	ENDP


SET_STACK_1	PROC

		ADD	EAX,3				;DWORD ALIGN IT...
		AND	AL,0FCH
		STACK_SIZE_FLAG = 0xFF;
		MOV	STACK_SIZE,EAX
		RET

SET_STACK_1	ENDP


if	fg_segm OR fg_pe

SET_HEAP	PROC
		;
		CALL	GET_COLON_NUMBER
		CALL	SET_HEAP_1
		;
if	fg_pe
		CALL	FIX_GET_COLON
		JNZ	L9$
		CALL	GET_NUMBER
		MOV	PEXEHEADER._PEXE_HEAP_COMMIT,EAX
endif

L9$:
		RET

SET_HEAP	ENDP


SET_HEAP_1	PROC

		ADD	EAX,3				;DWORD ALIGN IT...
		AND	AL,0FCH
		HEAP_SIZE_FLAG = 0xFF;
		MOV	HEAP_SIZE,EAX
		RET

SET_HEAP_1	ENDP

endif

if	fg_pe

SET_PE_BASE	PROC
		;
		;
		;
		CALL	GET_COLON_NUMBER
		MOV	PE_BASE,EAX
		PE_BASE_SPECIFIED = 0xFF;
		RET

SET_PE_BASE	ENDP


SET_PE_FIXED	PROC
		;
		;
		;
		PE_BASE_FIXED = 0xFF;
		RET

SET_PE_FIXED	ENDP


SET_MACHINE	PROC
		;
		;ONLY SUPPORTS i386, i486, PENTIUM
		;
		CALL	CHECK_COLON
		CALL	GET_KEYWORD
		PUSHM	EDI,ESI
		MOV	ECX,SYMBOL_LENGTH	;AT LEAST THIS MANY MUST MATCH
		MOV	ESI,OFF I386_TXT
		TEST	ECX,ECX
		MOV	EDI,OFF SYMBOL_TEXT
		JZ	L4$
		REPE	CMPSB
		JNZ	L4$
		POPM	ESI,EDI
if	fg_pe
		MOV	PEXEHEADER._PEXE_CPU_REQUIRED,PEXE_80386
endif
		RET

L4$:
		POPM	ESI,EDI
		MOV	AL,CMDLIN_ERR
		CALL	ERR_INBUF_RET
		RET

SET_MACHINE	ENDP


SET_VERSION	PROC
		;
		;
		;
		CALL	CHECK_COLON
		CALL	GET_NUM_DOT_NUM
if	fg_pe
		MOV	PEXEHEADER._PEXE_USER_MAJOR,AX
		MOV	PEXEHEADER._PEXE_USER_MINOR,DX
endif
		RET

SET_VERSION	ENDP

endif


if	fg_segm or fg_norm_exe OR fg_pe

SET_ALIGNMENT	PROC
		;
		CALL	GET_COLON_NUMBER
		MOV	ALIGNMENT,EAX		;MUST BE A POWER OF 2...
		ALIGNMENT_SPECIFIED = 0xFF;
		RET

SET_ALIGNMENT	ENDP

endif


SET_SEGMENTS	PROC
		;
		CALL	GET_COLON_NUMBER	;IGNORED...
		RET

SET_SEGMENTS	ENDP


if	fg_dospack

SET_PACKDOTS	PROC
		;
		DOTS_FLAG = 0xFF;
		RET

SET_PACKDOTS	ENDP


RES_PACKDOTS	PROC
		;
		DOTS_FLAG = 0;
		RET

RES_PACKDOTS	ENDP


SET_QUIKPACK	PROC
		;
		QUIKPACK_FLAG = 0xFF;

SET_SLRPACK	LABEL	PROC

		SLRPACK_SELECTED = 0xFF;
if	any_overlays
		MOV	COMPRESS_BYTE,'Y'
endif
		JMP	SET_EXEPACK_1

SET_QUIKPACK	ENDP

endif
#endif


void _set_nonames()
{
    KILL_NONRESIDENT_NAMES = 0xFF;
}

void _set_by_ordinal()
{
    ALL_EXPORTS_BY_ORDINAL = 0xFF;
}

#if 0
		.CONST

		ALIGN	4

EXE_TYPES	LABEL	DWORD

if	fg_pe
		DD	NT_STG,PE_EXE_TYPE
endif
		DD	WINDOWS_STG,WIN_SEGM_TYPE
		DD	OS2_STG,OS2_SEGM_TYPE
		DD	DOS_STG,DOS_EXE_TYPE
		DD	DOS4_STG,DOS4_SEGM_TYPE
		DD	DOSX_STG,DOSX_EXE_TYPE
		DD	UNKNOWN_STG,UNKNOWN_SEGM_TYPE

N_EXE_TYPES	EQU	($-EXE_TYPES)/8

SUBSYS_TYPES	LABEL	DWORD

		DD	PSUB_UNKNOWN_STG,PSUB_UNKNOWN
		DD	PSUB_NATIVE_STG,PSUB_NATIVE
		DD	PSUB_WIN_GUI_STG,PSUB_WIN_GUI
		DD	PSUB_WIN_CHAR_STG,PSUB_WIN_CHAR
		DD	PSUB_OS2_STG,PSUB_OS2
		DD	PSUB_POSIX_STG,PSUB_POSIX

N_SUBSYS_TYPES	EQU	($-SUBSYS_TYPES)/8


PSUB_UNKNOWN_STG	DB	'UNKNOWN',0
PSUB_NATIVE_STG		DB	'NATIVE',0
PSUB_WIN_GUI_STG	DB	'WINDOWS',0
PSUB_WIN_CHAR_STG	DB	'CONSOLE',0
PSUB_OS2_STG		DB	'OS2',0
PSUB_POSIX_STG		DB	'POSIX',0
#endif

void SET_ALIGNMENT();
//void SET_ALLOCATE();
void SET_PE_BASE();
void SET_BINARY();
//void SET_CACHE();
void CHECKSUM_PROC();
void SET_CODEVIEW();
void SET_CPARMAXALLOC();
void SET_CVVERSION();
void SET_CVWARNINGS();
void SET_DEBUGALL();
void SET_DEBUGBROWSERDEFS();
void SET_DEBUGCOVERAGES();
void HANDLE_DEBUGFILES();
void SET_DEBUGLINNUMS();
void SET_DEBUGLOCALS();
void HANDLE_DEBUGMODULES();
void SET_DEBUGPUBLICS();
void SET_DEBUGBROWSERREFS();
void SET_DEBUGTYPES();
void ERRORDELETE_PROC();
void DOSSEG_PROC();
//void SET_PACKDOTS();
void SET_ECHO_IND();
void SET_EMSMAXSIZE();
void SET_ENTRYPOINT();
void SET_EXEPACK();
void EXETYPE_PROC();
void SET_PE_FIXED();
//void SET_FORCEDEFINE();
void GROUPSTACK_PROC();
void SET_HEAP();
void MS_HELP();
//void SET_HIGH();
void IGNORECASE_PROC();
//void SET_INCREMENTAL();
void SET_IMPDEF();
void SET_IMPLIB();
void SET_IMPLIB_COFF();
void VERBOSE_PROC();
//void INTO_PROC();
void LOWERCASE_PROC();
void SET_MACHINE();
void MAKE_MAPOUT();
//void RES_MODEL_FAR();
void NOCHECKSUM_PROC();
void RES_DEBUGALL();
void RES_DEBUGBROWSERDEFS();
void RES_DEBUGCOVERAGES();
void RES_DEBUGLINNUMS();
void RES_DEBUGLOCALS();
void RES_DEBUGPUBLICS();
void RES_DEBUGBROWSERREFS();
void RES_DEBUGTYPES();
void RES_DEFAULTLIBRARYSEARCH();
void NOERRORDELETE_PROC();
//void RES_PACKDOTS();
void RES_ECHO_IND();
void NOGROUPSTACK_PROC();
void NOIGNORECASE_PROC();
void RES_LOGO_OUTPUT();
void NONULLSDOSSEG_PROC();
//void OVLCODELAST_PROC();
void RES_PACKFUNCTIONS();
//void NORENAME_PROC();
void RES_REORDER_ALLOWED();
void SET_NULLSDOSSEG();
void ONERROR_PROC();
//void SET_OVERLAYINTERRUPT();
//void OVLCODEFIRST_PROC();
void SET_PACKCODE();
void SET_PACKDATA();
void SET_PACKFUNCTIONS();
void PACKSIZE_PROC();
void SET_PADCODE();
void SET_PADDATA();
void SET_PAGESIZE();
void PMTYPE_PROC();
//void SET_QUIKPACK();
void RC_PROC();
//void SET_RELOAD();
void SET_REORDER_ALLOWED();
void SET_SEGMENTS();
void SILENT_PROC();
//void SET_SLRPACK();
//void SET_SOFTEXTRNS();
void SET_STACK();
void STUB_PROC();
void SUBSYSTEM_PROC();
//void SET_TDVERSION();
void SET_TINY();
//void SET_TLINK();
void UPPERCASE_PROC();
void SET_VERSION();
void SET_WINPACK();
void SET_XMSMAXSIZE();

typedef unsigned size_t;
typedef void (*fp_t)();
#define NULL ((void*)0)

fp_t _getcmd(char *cmd)
{
    struct Cmd
    {
	unsigned char len;
	unsigned char minlen;
	void (*fp)();
	char *str;
    };

    static struct Cmd cmds[] =
    {
	{    9,1, &SET_ALIGNMENT, "ALIGNMENT" },
	//{    8,3, &SET_ALLOCATE, "ALLOCATE" },
	{    4,3, &SET_PE_BASE, "BASE" },
	{    5,1, &_batch_proc, "BATCH" },
	{    6,2, &SET_BINARY, "BINARY" },
	{    9,3, &_set_by_ordinal, "BYORDINAL" },
	//{    5,2, &SET_CACHE, "CACHE" },
	{   10,6, &_set_abort_chk, "CHECKABORT" },
	{    8,6, &_enable_checkexe, "CHECKEXE" },
	{    8,6, &CHECKSUM_PROC, "CHECKSUM" },
	{    8,2, &SET_CODEVIEW, "CODEVIEW" },
	{   12,3, &_set_comdef_search, "COMDEFSEARCH" },
	{   12,2, &SET_CPARMAXALLOC, "CPARMAXALLOC" },
	{    9,3, &SET_CVVERSION, "CVVERSION" },
	{   10,3, &SET_CVWARNINGS, "CVWARNINGS" },
	{    5,3, &SET_DEBUGALL, "DEBUG" },
	{   14,6, &_set_debugapploader, "DEBUGAPPLOADER" },
	{   12,6, &SET_DEBUGBROWSERDEFS, "DEBUGBROWSER" },
	{   14,6, &SET_DEBUGCOVERAGES, "DEBUGCOVERAGES" },
	{   10,6, &HANDLE_DEBUGFILES, "DEBUGFILES" },
	{   10,7, &SET_DEBUGLINNUMS, "DEBUGLINES" },
	{   11,7, &SET_DEBUGLOCALS, "DEBUGLOCALS" },
	{   12,6, &HANDLE_DEBUGMODULES, "DEBUGMODULES" },
	{   12,6, &SET_DEBUGPUBLICS, "DEBUGPUBLICS" },
	{   15,6, &SET_DEBUGBROWSERREFS, "DEBUGREFERENCES" },
	{   10,6, &SET_DEBUGTYPES, "DEBUGTYPES" },
	{   20,3, &_set_defaultlibrarysearch, "DEFAULTLIBRARYSEARCH" },
	{   13,2, &ERRORDELETE_PROC, "DELEXECUTABLE" },
	{   11,3, &_set_detailedmap, "DETAILEDMAP" },
	{    6,2, &DOSSEG_PROC, "DOSSEG" },
	//{    4,3, &SET_PACKDOTS, "DOTS" },
	{   12,2, &SET_ECHO_IND, "ECHOINDIRECT" },
	{   10,4, &SET_EMSMAXSIZE, "EMSMAXSIZE" },
	{   14,4, &_set_ems_io_legal, "EMSPAGEFRAMEIO" },
	{    8,4, &_set_emsuse40, "EMSUSE40" },
	{    5,2, &SET_ENTRYPOINT, "ENTRY" },
	{    9,2, &_errorflag_proc, "ERRORFLAG" },
	{    7,1, &SET_EXEPACK, "EXEPACK" },
	{    7,4, &EXETYPE_PROC, "EXETYPE" },
	{   18,1, &_set_farcalltranslation, "FARCALLTRANSLATION" },
	{    5,2, &_fixds_proc, "FIXDS" },
	{    5,4, &SET_PE_FIXED, "FIXED" },
	//{ 11,2, &SET_FORCEDEFINE, "FORCEDEFINE" },
	{   16,1, &_set_groupassociation, "GROUPASSOCIATION" },
	{   10,6, &GROUPSTACK_PROC, "GROUPSTACK" },
	{    4,3, &SET_HEAP, "HEAP" },
	{    4,1, &MS_HELP, "HELP" },
	//{ 4,2, &SET_HIGH, "HIGH" },
	{   10,2, &IGNORECASE_PROC, "IGNORECASE" },
	//{ 11,3, &SET_INCREMENTAL, "INCREMENTAL" },
	{    6,4, &SET_IMPDEF, "IMPDEF" },
	{    6,4, &SET_IMPLIB, "IMPLIB" },
	{   10,7, &SET_IMPLIB_COFF, "IMPLIBCOFF" },
	{   11,1, &VERBOSE_PROC, "INFORMATION" },
	//{    4,3, &INTO_PROC, "INTO" },
	{   17,2, &_set_largeaddressaware, "LARGEADDRESSAWARE" },
	{   11,1, &_set_linenumbers, "LINENUMBERS" },
	{    9,2, &LOWERCASE_PROC, "LOWERCASE" },
	{    7,3, &SET_MACHINE, "MACHINE" },
	{    3,1, &MAKE_MAPOUT, "MAP" },
	//{    4,2, &RES_MODEL_FAR, "NEAR" },
	{    7,3, &_res_batch, "NOBATCH" },
	{   12,8, &_res_abort_chk, "NOCHECKABORT" },
	{   10,8, &_disable_checkexe, "NOCHECKEXE" },
	{   10,8, &NOCHECKSUM_PROC, "NOCHECKSUM" },
	{   10,4, &_res_codeview, "NOCODEVIEW" },
	{   14,5, &_res_comdef_search, "NOCOMDEFSEARCH" },
	{    8,4, &_res_cvpack, "NOCVPACK" },
	{    7,5, &RES_DEBUGALL, "NODEBUG" },
	{   16,8, &_res_debugapploader, "NODEBUGAPPLOADER" },
	{   14,8, &RES_DEBUGBROWSERDEFS, "NODEBUGBROWSER" },
	{   16,8, &RES_DEBUGCOVERAGES, "NODEBUGCOVERAGES" },
	{   12,9, &RES_DEBUGLINNUMS, "NODEBUGLINES" },
	{   13,9, &RES_DEBUGLOCALS, "NODEBUGLOCALS" },
	{   14,8, &RES_DEBUGPUBLICS, "NODEBUGPUBLICS" },
	{   17,8, &RES_DEBUGBROWSERREFS, "NODEBUGREFERENCES" },
	{   12,8, &RES_DEBUGTYPES, "NODEBUGTYPES" },
	{   22,3, &RES_DEFAULTLIBRARYSEARCH, "NODEFAULTLIBRARYSEARCH" },
	{   15,5, &NOERRORDELETE_PROC, "NODELEXECUTABLE" },
	{   13,5, &_res_detailedmap, "NODETAILEDMAP" },
	{    8,4, &_set_nodosseg, "NODOSSEG" },
	//{    6,5, &RES_PACKDOTS, "NODOTS" },
	{   14,4, &RES_ECHO_IND, "NOECHOINDIRECT" },
	{   16,6, &_res_ems_io_legal, "NOEMSPAGEFRAMEIO" },
	{   10,6, &_res_emsuse40, "NOEMSUSE40" },
	{   11,4, &_noerrorflag_proc, "NOERRORFLAG" },
	{    9,5, &_res_exepack, "NOEXEPACK" },
	{   15,3, &_res_extdictionary, "NOEXTDICTIONARY" },
	{   20,3, &_res_farcalltranslation, "NOFARCALLTRANSLATION" },
	{    7,4, &_res_fixds, "NOFIXDS" },
	{   18,3, &_res_groupassociation, "NOGROUPASSOCIATION" },
	{   12,8, &NOGROUPSTACK_PROC, "NOGROUPSTACK" },
	{   12,3, &NOIGNORECASE_PROC, "NOIGNORECASE" },
	{   13,4, &_res_linenumbers, "NOLINENUMBERS" },
	{    6,3, &RES_LOGO_OUTPUT, "NOLOGO" },
	{    5,3, &_no_make_mapout, "NOMAP" },
	{    7,4, &_set_nonames, "NONAMES" },
	{    8,4, &_res_nthost, "NONTHOST" },
	{   13,3, &NONULLSDOSSEG_PROC, "NONULLSDOSSEG" },
	//{   14,3, &OVLCODELAST_PROC, "NOOVLCODEFIRST" },
	{   10,3, &_res_packcode, "NOPACKCODE" },
	{   10,7, &_res_packdata, "NOPACKDATA" },
	{   15,7, &RES_PACKFUNCTIONS, "NOPACKFUNCTIONS" },
	{   18,7, &_res_packcode_no_segments, "NOPACKIFNOSEGMENTS" },
	{    7,5, &_res_pause, "NOPAUSE" },
	{    8,4, &_res_prompt_mode, "NOPROMPT" },
	{   17,3, &_res_relocation_check, "NORELOCATIONCHECK" },
	//{    8,5, &NORENAME_PROC, "NORENAME" },
	{   17,5, &RES_REORDER_ALLOWED, "NOREORDERSEGMENTS" },
	{    9,9, &_res_scanlib, "NOSCANLIB" },
	{   10,10, &_res_scanlink, "NOSCANLINK" },
	{   12,4, &_res_td, "NOTURBODEBUG" },
	{   10,7, &_res_warndups, "NOWARNDUPS" },
	{    9,4, &_res_winpack, "NOWINPACK" },
	{    6,3, &_no_make_xref, "NOXREF" },
	{    6,2, &_set_nthost, "NTHOST" },
	{   11,2, &SET_NULLSDOSSEG, "NULLSDOSSEG" },
	{    7,2, &ONERROR_PROC, "ONERROR" },
	{    3,3, &_set_optlink, "OPT" },
	//{   16,1, &SET_OVERLAYINTERRUPT, "OVERLAYINTERRUPT" },
	//{   12,3, &OVLCODEFIRST_PROC, "OVLCODEFIRST" },
	{    8,3, &SET_PACKCODE, "PACKCODE" },
	{    8,5, &SET_PACKDATA, "PACKDATA" },
	{   13,5, &SET_PACKFUNCTIONS, "PACKFUNCTIONS" },
	{   16,5, &_set_packcode_no_segments, "PACKIFNOSEGMENTS" },
	{    8,5, &PACKSIZE_PROC, "PACKSIZE" },
	{    7,4, &SET_PADCODE, "PADCODE" },
	{    7,4, &SET_PADDATA, "PADDATA" },
	{    8,3, &SET_PAGESIZE, "PAGESIZE" },
	{    5,3, &_set_pause, "PAUSE" },
	{    6,2, &PMTYPE_PROC, "PMTYPE" },
	{    6,2, &_set_prompt_mode, "PROMPT" },
	//{    9,1, &SET_QUIKPACK, "QUICKPACK" },
	{    2,2, &RC_PROC, "RC" },
	//{    6,5, &SET_RELOAD, "RELOAD" },
	{   15,5, &_set_relocation_check, "RELOCATIONCHECK" },
	{   15,3, &SET_REORDER_ALLOWED, "REORDERSEGMENTS" },
	{    7,7, &_set_scanlib, "SCANLIB" },
	{    8,8, &_set_scanlink, "SCANLINK" },
	{    8,2, &SET_SEGMENTS, "SEGMENTS" },
	{    7,4, &_set_segpack, "SEGPACK" },
	{    6,2, &SILENT_PROC, "SILENT" },
	//{    7,2, &SET_SLRPACK, "SLRPACK" },
	//{ 10,2, &SET_SOFTEXTRNS, "SOFTEXTRNS" },
	{    5,2, &SET_STACK, "STACK" },
	{    4,3, &STUB_PROC, "STUB" },
	{    9,2, &SUBSYSTEM_PROC, "SUBSYSTEM" },
	//{    9,3, &SET_TDVERSION, "TDVERSION" },
	{    4,1, &SET_TINY, "TINY" },
	//{    5,2, &SET_TLINK, "TLINK" },
	{   10,2, &_set_td, "TURBODEBUG" },
	{    9,1, &UPPERCASE_PROC, "UPPERCASE" },
	{    7,4, &SET_VERSION, "VERSION" },
	{    9,1, &_set_warnfixup, "WARNFIXUP" },
	{    8,5, &_set_warndups, "WARNDUPS" },
	{    7,2, &SET_WINPACK, "WINPACK" },
	{   10,2, &SET_XMSMAXSIZE, "XMSMAXSIZE" },
	{    4,1, &_make_xref, "XREF" },
	{   13,2, &_xnoignorecase_proc, "XNOIGNORECASE" },
	{   10,2, &_xupper_proc, "XUPPERCASE" }
    };

    //printf("_getcmd()\n");
    //printf("cmd = '%s'\n", cmd);
    size_t len = strlen(cmd);
    for (size_t i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++)
    {	struct Cmd *p = &cmds[i];
	if (p->minlen <= len && len <= p->len)
	{
	    if (memcmp(cmd, p->str, len) == 0)
	    {
		return p->fp;
	    }
	}
    }
    return NULL;
}

void printx(void *p)
{
    printf("fp = %p\n", p);
}

char PM_STG[] = "PM";
char VIO_STG[] = "VIO";
char NOVIO_STG[] = "NOVIO";


void *PM_TYPES[6] = {	PM_STG, (void *)0x300,
			VIO_STG, (void *)0x200,
			NOVIO_STG, (void *)0x100
		};


char NT_STG[] = "NT";
char OS2_STG[] = "OS2";
char WINDOWS_STG[] = "WINDOWS";
char DOS_STG[] = "DOS";
char DOS4_STG[] = "DOS4";
char DOSX_STG[] = "DOSX";
char UNKNOWN_STG[] = "UNKNOWN";

char FULL_TEXT[] = "FULL";
char ADDRESS_TEXT[] = "ADDRESS";
char GROUP_TEXT[] = "GROUP";
char NOGROUP_TEXT[] = "NOGROUP";

char NOEXE_TXT[] = "NOEXE";
char I386_TXT[] = "I386";


void _switch_help()
{
    printf("\
A[lignment]               BAS[e]                    B[atch]\n\
BI[nary]                  BYO[rdinal]               CHECKA[bort]\n\
CHECKE[xe]                CHECKS[um]                CO[deview]\n\
COM[defsearch]            CP[armaxalloc]            CVV[ersion]\n\
CVW[arnings]              DEB[ug]                   DEBUGA[pploader]\n\
DEBUGB[rowser]            DEBUGC[overages]          DEBUGF[iles]\n\
DEBUGLI[nes]              DEBUGLO[cals]             DEBUGM[odules]\n\
DEBUGP[ublics]            DEBUGR[eferences]         DEBUGT[ypes]\n\
DEF[aultlibrarysearch]    DE[lexecutable]           DET[ailedmap]\n\
DO[sseg]                  EC[hoindirect]            EMSM[axsize]\n\
EMSP[ageframeio]          EMSU[se40]                EN[try]\n\
ER[rorflag]               E[xepack]                 EXET[ype]\n\
F[arcalltranslation]      FI[xds]                   FIXE[d]\n\
G[roupassociation]        GROUPS[tack]              HEA[p]\n\
H[elp]                    IG[norecase]              IMPD[ef]\n\
IMPL[ib]                  IMPLIBC[off]              I[nformation]\n\
LA[RGEADDRESSAWARE]       L[inenumbers]             LO[wercase]\n\
MAC[hine]                 M[ap]                     NOB[atch]\n\
NOCHECKA[bort]            NOCHECKE[xe]              NOCHECKS[um]\n\
NOCO[deview]              NOCOM[defsearch]          NOCV[pack]\n\
NODEB[ug]                 NODEBUGA[pploader]        NODEBUGB[rowser]\n\
NODEBUGC[overages]        NODEBUGLI[nes]            NODEBUGLO[cals]\n\
NODEBUGP[ublics]          NODEBUGR[eferences]       NODEBUGT[ypes]\n\
NOD[efaultlibrarysearch]  NODEL[executable]         NODET[ailedmap]\n\
NODO[sseg]                NOEC[hoindirect]          NOEMSP[ageframeio]\n\
NOEMSU[se40]              NOER[rorflag]             NOEXE[pack]\n\
NOE[xtdictionary]         NOF[arcalltranslation]    NOFI[xds]\n\
NOG[roupassociation]      NOGROUPS[tack]            NOI[gnorecase]\n\
NOLI[nenumbers]           NOL[ogo]                  NOM[ap]\n\
NONA[mes]                 NONT[host]                NON[ullsdosseg]\n\
NOP[ackcode]              NOPACKD[ata]              NOPACKF[unctions]\n\
NOPACKI[fnosegments]      NOPAU[se]                 NOPR[ompt]\n\
NOR[elocationcheck]       NOREO[rdersegments]       NOSCANLIB\n\
NOSCANLINK                NOWARND[ups]              NOWI[npack]\n\
NOX[ref]                  NT[host]                  NU[llsdosseg]\n\
ON[error]                 OPT                       PAC[kcode]\n\
PACKD[ata]                PACKF[unctions]           PACKI[fnosegments]\n\
PACKS[ize]                PADC[ode]                 PADD[ata]\n\
PAG[esize]                PAU[se]                   PM[type]\n\
PR[ompt]                  RC                        RELOC[ationcheck]\n\
REO[rdersegments]         SCANLIB                   SCANLINK\n\
SE[gments]                SEGP[ack]                 SI[lent]\n\
ST[ack]                   STU[b]                    SU[bsystem]\n\
T[iny]                    U[ppercase]               VERS[ion]\n\
W[arnfixup]               WARND[ups]                WI[npack]\n\
XM[smaxsize]              X[ref]                    XN[oignorecase]\n\
XU[ppercase]\n\
");
}

